<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>workerman</title>
</head>
<body>

内容: <input type="text" id="test1" >
<button type="submit" id="btn" onclick="Submit()" >提交</button>

</body>

<div id="div_box">

</div>

<script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
<script>
    ws = new WebSocket("ws://tp6wk.chenxianlei.com:2346");
    ws.onopen = function() {
    };

    function Submit() {
        var uid1 = document.getElementById('test1').value;
        ws.send(uid1);
        document.getElementById('test1').value="";
    }

    ws.onmessage = function(e){
        // console.log(e.data);
        $('#div_box').after('<div id="div_box">\n' +
            '\n' + e.data +
            '</div>')
    };

</script>

</html>
